<?php

namespace App\Http\Controllers\Admin\Anchor;

use App\Http\Controllers\Controller as BaseController;
use App\Repository\Anchor\AnchorStatsRepository;
use Illuminate\Http\Request;

// 主播
class StatsController extends BaseController
{
    private $repoist;

    public function __construct(AnchorStatsRepository $repository)
    {
        $this->repoist = $repository;
    }

    public function index(Request $request)
    {
        $where = [];
        if (!$request->has('dateRange') || empty($request->get('dateRange'))) {
            $request->merge(['dateRange' => [date('Y-m') . '-01', date('Y-m-d')]]);
        }

        $data = [];
        $data['dataList'] = array_column($this->repoist->stats($request), null);
        $data['dateRange'] = $request->get('dateRange');
        return $this->returnMsg(200, '统计完毕', $data);
    }

//明细
    public function details(Request $request)
    {
        return $this->repoist->details($request);
    }
}
